﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/ADAdminLayout.master" AutoEventWireup="true"
    CodeFile="chi_tiet_khuyen_mai.aspx.cs" Inherits="chi_tiet_khuyen_mai" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<link href="../themes/blue/css/item.css" rel="stylesheet" type="text/css" />
 <div class="content">
        <asp:HiddenField ID="HidH" runat="server" Value="0" />
    <asp:HiddenField ID="HidM" runat="server" Value="0" />
    <asp:HiddenField ID="HidS" runat="server" Value="0" />
    <asp:HiddenField ID="HidRemainingTime" runat="server" Value="0" />
    <asp:HiddenField ID="HidHoursLabelID" runat="server" Value="0" />
    <asp:HiddenField ID="HidMinutesLabelID" runat="server" Value="0" />
    <asp:HiddenField ID="HidSecondsLabelID" runat="server" Value="0" />
    <asp:Button ID="Button1" runat="server" Text="Duyệt Deal này" 
            onclick="Button1_Click" />
    <div class="content">
        <asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" 
            OnDataBound="ListView1_DataBound" onitemdatabound="ListView1_ItemDataBound">
            <ItemTemplate>
                <!-- 
            <%# HidRemainingTime.Value= Eval("con_lai").ToString()%>                     
            -->
                <div id="deal-intro" class="cf">
                    <h1>
                        <a class="deal-today-link" href="#">Deal:</a>
                        <%# Eval("mo_ta_sp") %>
                        
                    </h1>
                    <div class="main">
                        <div class="deal-buy">
                            <div class="deal-price-tag">
                            </div>
                            <p class="deal-price">
                                <strong>
                                    <%# Eval("gia_km") %>
                                    <br>
                                    VNĐ </strong><span><a href="buy.aspx">
                                        <img src="../themes/blue/images/button-deal-buy.png"></a> </span>
                            </p>
                        </div>
                        <table class="deal-discount">
                            <tbody>
                                <tr>
                                    <td colspan="3" align="center" style="padding-top: 15px; padding-bottom: 15px; border-bottom: #339A99 1px solid">
                                        <span style="font: bold 1.3em arial">Giá gốc:&nbsp;<%# Eval("gia_goc") %></span></td>
                                </tr>
                                <tr>
                                    <td width="50%" style="border-right: #339A99 1px solid; padding-top: 10px" valign="top">
                                        Giảm giá<br>
                                        <span style="font: bold 1.1em arial">
                                            <%# Eval("giam") %>%</span>
                                    </td>
                                    <td width="50%" valign="top" style="padding-top: 10px">
                                        Tiết kiệm<br>
                                        <span style="font: bold 1.1em arial">
                                            <%# Eval("tiet_kiem") %></span>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <div class="deal-box deal-timeleft deal-on" id="deal-timeleft" curtime="1333893619000"
                            diff="442780000">
                            <h3>
                                Thời gian còn lại</h3>
                            <div class="limitdate">
                                <ul id="counter" style="list-style: none;">
                                    <li><b><span>
                                        <asp:Label runat="server" Text="Label" ID="lbHours" /></span>Giờ</b> </li>
                                    <li><b><span>
                                        <asp:Label runat="server" Text="Label" ID="lbMinutes" /></span>Phút</b> </li>
                                    <li><b><span>
                                        <asp:Label runat="server" Text="Label" ID="lbSeconds" /></span>Giây</b></li>
                                </ul>
                            </div>
                        </div>
                        <div class="deal-box deal-status deal-status-open" id="deal-status">
                            <p class="deal-buy-tip-top">
                                <asp:Label runat="server" Text="Label" ID="lbBought" />
                            </p>
                            <p class="deal-buy-tip-btm">
                                <asp:Label runat="server" Text="Label" ID="lbRemain" />
                            </p>
                            <p class="deal-buy-on" style="line-height: 200%;">
                                <asp:Label runat="server" Text="Label" ID="lbCanBuy" />
                            </p>
                        </div>
                    </div>
                    <div class="side">
                        <div class="deal-buy-cover-img" id="team_images">
                            <div class="mid">
                                <ul>
                                    <li class="first" style="opacity: 1; left: 0Px;">
                                        <img src='<%# "../upload/"+Eval("anh_1")%>'></li>
                                </ul>
                            </div>
                        </div>
                        <div align="justify" style="padding-top: 10px; width: 680px;">
                            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                <tbody>
                                    <tr>
                                        <td style="font-weight: bold;" width="50%">
                                            <span style="font-size: medium; color: #80b04f;">Điểm nổi bật:<br>
                                            </span>
                                        </td>
                                        <td style="border-left: 1px solid rgb(204, 204, 204);">
                                            &nbsp;
                                        </td>
                                        <td style="padding-left: 10px; font-weight: bold;">
                                            <p>
                                                <span style="font-size: medium; color: #80b04f;">Điều kiện:</span></p>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="padding-left: 10px; padding-right: 10px;" valign="top" align="justify">
                                            <div align="justify">
                                            </div>
                                            <span style="font-weight: bold;"></span>
                                            <%# Eval("dac_trung") %>
                                        </td>
                                        <td style="border-left: 1px solid rgb(204, 204, 204);">
                                            <strong>
                                                <br>
                                            </strong>
                                        </td>
                                        <td style="padding-left: 20px;" valign="top" align="left">
                                            <%# Eval("dieu_kien_ap_dung") %>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <br>
                            <br>
                        </div>
                    </div>
                </div>
            </ItemTemplate>
        </asp:ListView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:babydealConnectionString %>"
            
            SelectCommand="SELECT id, ten_sp, mo_ta_sp, ngay_bat_dau, ngay_ket_thuc, DATEDIFF(s ,GETDATE() ,ngay_ket_thuc)  AS con_lai, gia_km, gia_goc,  (gia_goc - gia_km) as tiet_kiem,(gia_goc - gia_km) * 100 / gia_goc AS giam, so_luong_toi_da, so_luong_toi_thieu, noi_dung, dieu_kien_ap_dung, dac_trung, da_duoc_duyet, anh_1 FROM khuyen_mai WHERE (id = @id)">
            <SelectParameters>
                <asp:QueryStringParameter Name="id" QueryStringField="id" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        <div id="deal-stuff" class="cf">
            <div class="clear box box-split">
                <div class="box-top">
                </div>
                <div class="box-content cf">
                    <div class="main" id="team_main_side" style="width:989px">
                        <h2 id="detail">
                            Thông tin
                        </h2>
                        <asp:ListView ID="ListView2" runat="server" DataSourceID="SqlDataSource1">
                            <ItemTemplate>
                                <div class="blk detail">
                                    <%# Eval("noi_dung") %>
                                </div>
                            </ItemTemplate>
                        </asp:ListView>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        var hours = document.getElementById("<% =HidH.ClientID %>").value;
        var minutes = document.getElementById("<% =HidM.ClientID %>").value;
        var seconds = document.getElementById("<% =HidS.ClientID %>").value;
        var hoursLabel = document.getElementById("<% =HidHoursLabelID.ClientID %>").value;
        var minutesLabel = document.getElementById("<% =HidMinutesLabelID.ClientID %>").value;
        var secondsLabel = document.getElementById("<% =HidSecondsLabelID.ClientID %>").value;
        function display() {
            if (seconds <= 0) {
                if ((hours == 0) && (minutes == 0))
                    seconds = 0;
                else {
                    seconds = 60;
                    minutes -= 1;
                }

            }
            if (minutes <= 0) {
                if ((hours < 0) && (minutes < 0)) {
                    hours = minutes = seconds = 0;
                }
                else {
                    if ((hours == 0) && (minutes == 0))
                        hours = minutes = 0;
                    if ((hours > 0) && (minutes < 0)) {
                        minutes = 59;
                        hours -= 1;
                    }
                }
            }
            if ((minutes <= -1) || (hours <= -1)) {
                if (hours <= -1) {
                    minutes = 0;
                    hours += 1;
                }
                else
                    minutes -= 1;
                seconds = 0;
                minutes += 1;
            }
            else
                if (seconds > 0)
                    seconds -= 1;
            document.getElementById(hoursLabel).innerHTML = hours;
            document.getElementById(minutesLabel).innerHTML = minutes;
            document.getElementById(secondsLabel).innerHTML = seconds;

            setTimeout("display()", 1000);
        }
        display();
    </script>
    </div>
</asp:Content>
